#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

unordered_map<string, int> mp;
string s;

bool check(char ch) {
    if (ch >= 'A' && ch <= 'Z') return true;
    if (ch >= 'a' && ch <= 'z') return true;
    if (ch >= '0' && ch <= '9') return true;
    return false;
}

inline void solution() {
    getline(cin, s);
    for (int i = 0; i < s.size(); i ++ ) {
        if (check(s[i])) {
            string word = "";
            int j = i;
            while (j < s.size() && check(s[j])) 
                word += tolower(s[j ++ ]);
            i = j;
            mp[word] ++ ;
        }
    }
    string w;
    int res = -1;
    for (auto& x : mp) 
        if (x.second > res || x.second == res && x.first < w) 
            w = x.first, res = x.second;
    cout << w << " " << res << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}